$(function () {

	var rules = {
		    	rules: {
					name: {
                        minlength: 2,
                        required: true
                    },
                    email: {
						required: true,
						email: true
					},
					subject: {
						minlength: 2,
						required: true
					},
					message: {
						minlength: 2,
						required: true
					},
			        validateSelect: {
			      	required: true
		      	    },
			        validateCheckbox: {
			      	required: true,
			      	minlength: 2	
		      	    },
			        validateRadio: {
			      	required: true
			        }
				}
		    };
		
	    var validationObj = $.extend (rules, Theme.validationRules);
	    
		$('form').validate(validationObj);
		
});

var Theme = function () {


    var validationRules = getValidationRules ();



    return {validationRules: validationRules };



    function getValidationRules () {
        var custom = {
            focusCleanup: false,

            wrapper: 'div',
            errorElement: 'span',

            highlight: function(element) {
                $(element).parents ('.control-group').removeClass ('success').addClass('error');
            },
            success: function(element) {
                $(element).parents ('.control-group').removeClass ('error').addClass('success');
                $(element).parents ('.controls:not(:has(.clean))').find ('div:last').before ('<div class="clean"></div>');
            },
            errorPlacement: function(error, element) {
                error.appendTo(element.parents ('.controls'));
            }

        };

        return custom;
    }

}();
